From: Julian Sparber Date: Thu, 15 Feb 2024 16:41:29 +0000 (+0100) Subject: GTKNotificationDaemon: Use ShellApp methods to activate apps X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~1^2~110 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7d6f465a47b15d8830d8ebe835b72bbbccbf4b63;p=gnome-shell.git GTKNotificationDaemon: Use ShellApp methods to activate apps `ShellApp` gained the ability to activated actions and it sets the correct platform data. Therefore drop the current implementation in favor for it. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7409 Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5239 Part-of: --- diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index d6aa3811c..4aceb2468 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -472,28 +472,12 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification { } }); -const FdoApplicationIface = loadInterfaceXML('org.freedesktop.Application'); -const FdoApplicationProxy = Gio.DBusProxy.makeProxyWrapper(FdoApplicationIface); - -function objectPathFromAppId(appId) { - return `/${appId.replace(/\./g, '/').replace(/-/g, '_')}`; -} - -/** - * @returns {{ 'desktop-startup-id': string }} - */ -function getPlatformData() { - let startupId = GLib.Variant.new('s', `_TIME${global.get_current_time()}`); - return {'desktop-startup-id': startupId}; -} - function InvalidAppError() {} export const GtkNotificationDaemonAppSource = GObject.registerClass( class GtkNotificationDaemonAppSource extends MessageTray.Source { constructor(appId) { - const objectPath = objectPathFromAppId(appId); - if (!GLib.Variant.is_object_path(objectPath)) + if (!Gio.Application.id_is_valid(appId)) throw new InvalidAppError(); const app = Shell.AppSystem.get_default().lookup_app(`${appId}.desktop`); @@ -508,47 +492,26 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source { this._appId = appId; this._app = app; - this._objectPath = objectPath; this._notifications = {}; this._notificationPending = false; } - _createApp() { - return new Promise((resolve, reject) => { - new FdoApplicationProxy(Gio.DBus.session, - this._appId, this._objectPath, (proxy, err) => { - if (err) - reject(err); - else - resolve(proxy); - }); - }); - } - _createNotification(params) { return new GtkNotificationDaemonNotification(this, params); } - async activateAction(actionId, target) { - try { - const app = await this._createApp(); - const params = target ? [target] : []; - app.ActivateActionAsync(actionId, params, getPlatformData()); - } catch (error) { - logError(error, 'Failed to activate app proxy'); - } + activateAction(actionId, target) { + const params = target ? GLib.Variant.new('av', [target]) : null; + this._app.activate_action(actionId, params, 0, -1, null).catch(error => { + logError(error, `Failed to activate action for ${this._appId}`); + }); Main.overview.hide(); Main.panel.closeCalendar(); } - async open() { - try { - const app = await this._createApp(); - app.ActivateAsync(getPlatformData()); - } catch (error) { - logError(error, 'Failed to open app proxy'); - } + open() { + this._app.activate(); Main.overview.hide(); Main.panel.closeCalendar(); }